package net.mingsoft.message_center.action.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.message_center.action.q.MessageListQuery;
import net.mingsoft.message_center.action.r.MessageResponse;
import net.mingsoft.message_center.biz.MessageBiz;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author gengfa
 * @date 22/01/24
 */
@Api(value = "消息中心接口", tags = {"消息中心"})
@Controller("WebMessageCenterAction")
@RequestMapping("/${ms.manager.path}/message-center")
public class MessageCenterAction {

    @Resource
    MessageBiz messageBiz;

    @GetMapping("/index")
    public String index(HttpServletResponse response, HttpServletRequest request){
        return "/message-center/index";
    }

    @ApiOperation(value = "消息列表")
    @PostMapping(value = "/list", consumes = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponse(code = 0, message = "success", response = MessageResponse.class)
    @ResponseBody
    public ResultData list(@RequestBody MessageListQuery query) {
        Page<MessageResponse> page = messageBiz.list(query);
        return ResultData.build().success(page);
    }
}
